<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
 
<%@ page import="org.limp.mine.Label"%>
<%@ page import="org.limp.mine.Controller"%>	
<%@ page import="org.limp.mine.DateTrimmer"%>
<% 
    String context = jt.classic.system.ISystem.getContextPath();
	Object[] result = (Object[])request.getAttribute("result");	
	Label label = (Label)result[1];
	Controller controller = (Controller)result[2];	
	String pageNO = (String)result[3];
	List resultList = (List) result[0];
	
	String spjhname = (String)request.getAttribute("spjhname");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>商品集合列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<jsp:include page="../../head.jsp"></jsp:include>
<script language="javascript">
  var chk = false;
  function checkall(thizz){
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox"){
        chks[i].checked = !chk;
      }
    }
    chk = !chk;
  }
 
  function handleQuery(){
    document.form2.action = context + "/app/shangpin.do?method=list_spjh&type=select";
    document.form2.submit();
  }
  
 
  function handleEdit(id){
      //var url = "<%=context%>/app/shangpin.do?method=edit&id=" + id;
     // window.location.href = url;
  }  
   
  function handleReresh(){
      window.location.href = context + "/app/shangpin.do?method=list_spjh&type=select&pageNO=<%=pageNO%>";
  }
  
  /**
  *选择商品集合
  */
 function handleSelect(){
    var rnt = false;
    var ids = "";
    var names = "";
    var chks = document.getElementsByTagName("input");
    for(var i=0;i<chks.length;i++){
      if(chks[i].type == "checkbox" && chks[i].checked&&chks[i].value!=""){
        rnt = true;
        ids += chks[i].value + ",";
        names += document.getElementById(chks[i].value).value + ",";
      }
    }
    ids = ids.substring(0,ids.length-1);
    names = names.substring(0,names.length-1);
   
    if(ids!=""){
    	addsp(ids,names);
    	parent.closeDialog();
    }
  }
    /**
   *向父窗口添加商品集合
   */
    function addsp(ids,names){ 
     //document.form2.ids.value = ids;
     var n = names.split(",");
     var d = ids.split(",");
     var txt = "";
     for(var i=0;i<n.length;i++){
         if(!parent.document.getElementById(d[i])){
         txt += " <div id='"+d[i]+"' dtype='sp_obj' dname='"+n[i]+"'>" ;
         txt += n[i] ;
         txt += "&nbsp;&nbsp;<span title='删除' style='cursor:hand;' onclick=\"javascript:handleRemove('"+d[i]+"');\">×</span></div>";
         }
     }
    
     var fs_spjh = window.parent.document.getElementById("fs_spjh");
     fs_spjh.innerHTML = fs_spjh.innerHTML + txt;
     }  
</script>
<body>
<form name="form2" method="post" action="">
<input type="hidden" name="pageNO" value="<%=pageNO%>">
<!-- 状态为审核通过 -->
<input type=hidden id=spstatus name=spstatus value=1 />
<input type="text" class="box3" name="spjhname" value="<%=spjhname%>"> 
      <input type="button" class="button0" value=" 查 询 " onclick="javascript:handleQuery();">
      <input type="button" class="button0" value=" 确 定 " onclick="javascript:handleSelect();">
<table class="tbl" border="0" width="98%" cellspacing="0" cellpadding="0">
  <tr class="tr0" bgcolor="#A7CADE"> 
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" title="全部选择/取消选择" onclick="javascript:checkall();" width="10" align="center">&nbsp;</td>
    <td class="td0" background="<%=context%>/app/images/bg_lm.jpg" width="90%">&nbsp;商品集合名称</td> 
  </tr>
  <% 
    if(resultList!=null&&!resultList.isEmpty()){
    
       for(int i=0;i<resultList.size();i++){
	       Map info = (Map)resultList.get(i);
	       String number = (String)info.get("PAGINATION_NUMBER");
	       String SPJH_ID = info.get("SPJH_ID").toString();
	       String SPJH_NAME = info.get("SPJH_NAME").toString(); 
	       String SPJH_STATUS = info.get("SPJH_STATUS").toString();
	          
  %> 
  <tr onMouseOver="javascript:this.bgColor='#ffff99'" onmouseout=" javascript:this.bgColor='#F5F7F9'" bgColor="#F5F7F9"> 
    <td class="td1" align="center">
    <input type="checkbox" name="chk" id="chk_<%=SPJH_ID%>" value="<%=SPJH_ID%>">
    <input type=hidden id="<%=SPJH_ID%>" value="<%=SPJH_NAME%>">
    </td>
    <td class="td1">&nbsp;<a href="javascript:void(0);" onclick="javascript:handleEdit('<%=SPJH_ID%>');"><%=SPJH_NAME%></a></td> 
  </tr>
  <script>
    if(parent.document.getElementById("<%=SPJH_ID%>")){
       document.getElementById("chk_<%=SPJH_ID%>").checked = true;
    }
  </script>
  <%
        }
     }
  %>
</table> 
<table width="98%" class="tab-noborder" border="0" cellspacing="0" cellpadding="0">
  <tr>
   <td>
    <%=label.displayLabel()%>
   </td>
   <td align="right">
        <%=label.startLabel()%>
        <%=label.previousLabel()%>
        <%=label.nextLabel()%>
        <%=label.endLabel()%>
        <%=controller.getController().toString()%>
    </td>
  </tr>
</table>  
<%=controller.getControlScript(true)%> 
</form>
</body>
</html>	